import service from '@/request/index.js'

// import { getCurrentDate } from '@/tools/index.js'


// 首页banner
export const fetchBanner = () => {
    return service.get('/Banner')
}


// 首页推荐列表
export const fetchHomeRecommend = () => {
    return service.get('/HomeRecommend')
}

// 榜单
export const fetchRanking = (type) => {
    return service.get(`/HomeHot?type=${type}`)
}

//分类筛选条件
export const fetchCategory = () => {
    return service.get('/AllLabel')
}

// 分类筛选结果列表
/*
* @param {number} style_id  分类id  -1全部
* @param {number} area_id   地区id  -1全部
* @param {number} is_finish   连载状态   -1全部   0 连载  1 完结
* @param {number} is_free   付费情况  -1全部
* @param {number} order   排序规则  0
* @param {number} page_num   分页页码 1
* @param {number} page_size   分页大小  15
* @param {number} special_id   特殊ID（可选）
*/
export const fetchList = (style_id = -1, area_id = -1, is_finish = -1, order = 0, is_free = -1, page_num = 1, page_size = 15, special_id) => {
    let url = `/ClassPage?style_id=${style_id}&area_id=${area_id}&is_finish=${is_finish}&order=${order}&is_free=${is_free}&page_num=${page_num}&page_size=${page_size}`;

    // 只有当 special_id 有值时才添加到 URL 中
    if (special_id !== undefined && special_id !== null) {
        url += `&special_id=${special_id}`;
    }

    return service.get(url);
}


// 漫画详情
export const fetchComicDetail = (id) => {
    return service.get(`/ComicDetail?comic_id=${id}`);
}

// 热门评论
export const fetchComicHotComments = (id) => {
    return service.get(`/reply?oid=${id}`);
}

// 猜你喜欢
export const fetchRecommended = (id) => {
    return service.get(`/Recommend?comic_id=${id}`);
}

// 获取图片
export const fetchImg = (id) => {
    return service.get(`/GetImageIndex?ep_id=${id}`);
}

// 获取图片token
export const fetchImgFromToken = (path) => {
    const pathsArray = [path]; // 将单个字符串包装成数组
    return service.get(`/ImageToken?urls=${JSON.stringify(pathsArray)}`);

}